Skip to content

Conversation

@codyde
Copy link
Contributor

@codyde codyde commented Jun 11, 2025

Adds support for .md at the end of every pre-rendered path. Does this by a hack where we rewrite those paths to public/md-exports/.... The contents of this directory are generated after next build by scraping all html files under .next/server/app

Not ideal but looks like the easiest path for now.

Also added a "View Markdown version" link to pages:

image

@codyde codyde added the WIP label Jun 11, 2025
@vercel
Copy link

vercel bot commented Jun 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
develop-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2025 11:53am
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2025 11:53am

@codecov
Copy link

codecov bot commented Jun 11, 2025

Bundle Report

Changes will increase total bundle size by 30.67kB (0.15%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 10.92MB 1.39kB (0.01%) ⬆️
sentry-docs-client-array-push 9.8MB 29.28kB (0.3%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: sentry-docs-client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
static/chunks/pages/_app-*.js -3 bytes 873.24kB -0.0%
static/css/*.css 48 bytes 741.21kB 0.01%
static/chunks/7750-*.js 13.97kB 415.8kB 3.48%
static/chunks/main-*.js 15.17kB 133.44kB 12.82% ⚠️
static/chunks/main-*.js -13 bytes 1.66kB -0.78%
static/chunks/app/[[...path]]/page-*.js 44 bytes 83.21kB 0.05%
server/middleware-*.js -5.55kB 1.0kB -84.74%
server/middleware-*.js 5.55kB 6.55kB 555.3% ⚠️
static/lkyrdpjcr5ErzVPHDuGnd/_buildManifest.js (New) 684 bytes 684 bytes 100.0% 🚀
static/lkyrdpjcr5ErzVPHDuGnd/_ssgManifest.js (New) 77 bytes 77 bytes 100.0% 🚀
static/_i4kAFJ1NHhjfH7Fdh5YR/_buildManifest.js (Deleted) -616 bytes 0 bytes -100.0% 🗑️
static/_i4kAFJ1NHhjfH7Fdh5YR/_ssgManifest.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️
view changes for bundle: sentry-docs-server-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
1729.js -3 bytes 1.64MB -0.0%
4288.js (New) 1.04MB 1.04MB 100.0% 🚀
../instrumentation.js -3 bytes 973.36kB -0.0%
9523.js -3 bytes 949.31kB -0.0%
../app/[[...path]]/page.js 44 bytes 590.82kB 0.01%
9273.js 1.43kB 84.53kB 1.72%
9567.js -1 bytes 18.65kB -0.01%
2637.js (Deleted) -1.04MB 0 bytes -100.0% 🗑️

Files in ../app/[[...path]]/page.js:

  • ./src/components/apiExamples/apiExamples.tsx → Total Size: 471 bytes

  • ./src/components/codeBlock/index.tsx → Total Size: 1.3kB

Files in 9273.js:

  • ./src/components/docPage/index.tsx → Total Size: 10.3kB

  • ./src/components/breadcrumbs/index.tsx → Total Size: 1.14kB

  • ./src/icons/Markdown.tsx → Total Size: 1.22kB

Files in 9567.js:

  • ./src/mdx.ts → Total Size: 18.16kB

App Routes Affected:

App Route Size Change Total Size Change (%)
/[[...path]] 44 bytes 3.14MB 0.0%

Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks pretty solid to me!

The script adds more than 3min to every build now, which will only grow in the future.
@BYK just thinking loud but do you see any chance we could create these at runtime on request? I imagine performance is not the biggest concern for these pages?

And last point we probably don't want these pages to show up in google, can we add the according meta tag for these pages?

next.config.ts Outdated
};

if (
!process.env.NODE_ENV &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m: Is this one intended? This condition will always fail, even when NODE_ENV is production

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intended as otherwise yarn build fails locally, asking for these DSNs. That said I think the negation at the front is incorrect. I wonder how this worked locally.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay reverted this as next build sets NODE_ENV to production by default if it was not set 😮

Added a yarn start:dev command instead to do what I needed.

removing leftover log text
@BYK
Copy link
Member

BYK commented Jun 20, 2025

@chargome

The script adds more than 3min to every build now, which will only grow in the future.

Yeah, we have 8k+ files so it takes a while. That said I do not think the build time will grow significantly as even if you added 100 more docs it's still about 10% of the total docs we have and need to walk through.

@BYK just thinking loud but do you see any chance we could create these at runtime on request? I imagine performance is not the biggest concern for these pages?

As far as I'm aware Next.js does not allow the *.md routing. I think if we can figure out the routing, this should be doable. I also proposed adding a front-proxy, probably using Cloudflare, that can do all this stuff on the fly and cache it. Not sure if Vercel Functions may also help with this.

And last point we probably don't want these pages to show up in google, can we add the according meta tag for these pages?

Where should I add these tags? These pages are not linked from anywhere (except from the link I just added and I'll add rel=nofollow to them right after posting this message) so not sure how they would end up in Google. Also I cannot add meta tags to MD files, do you mean some sort of a header or something?

@chargome
Copy link
Member

As far as I'm aware Next.js does not allow the *.md routing. I think if we can figure out the routing, this should be doable. I also proposed adding a front-proxy, probably using Cloudflare, that can do all this stuff on the fly and cache it. Not sure if Vercel Functions may also help with this.

Is the .md essential for LLMs? Otherwise we could possibly just add a search param ?md=true and e.g. redirect to a dynamic route instead.

Also I cannot add meta tags to MD files, do you mean some sort of a header or something?

Nevermind, I thought the HTML came from the server here – ignore my comment 👍

Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway I don't want to block this, we can look into optimizing this 🚀

@BYK BYK merged commit 5076ac2 into master Jun 20, 2025
14 checks passed
@BYK BYK deleted the cursor/convert-page-to-markdown-format-39de branch June 20, 2025 11:53
@BYK
Copy link
Member

BYK commented Jun 20, 2025

Is the .md essential for LLMs? Otherwise we could possibly just add a search param ?md=true and e.g. redirect to a dynamic route instead.

Yeah we want the .md part without redirects as that's the best user experience and what seems to be established in the industry.

I'll work on a patch to speed things up using NextJS build cache.

antonpirker pushed a commit that referenced this pull request Jun 24, 2025
…3994)

Adds support for `.md` at the end of every pre-rendered path. Does this
by a hack where we rewrite those paths to `public/md-exports/...`. The
contents of this directory are generated _after_ `next build` by
scraping all html files under `.next/server/app`

Not ideal but looks like the easiest path for now.

---------

Co-authored-by: Burak Yigit Kaya <[email protected]>
bitsandfoxes pushed a commit that referenced this pull request Jul 3, 2025
…3994)

Adds support for `.md` at the end of every pre-rendered path. Does this
by a hack where we rewrite those paths to `public/md-exports/...`. The
contents of this directory are generated _after_ `next build` by
scraping all html files under `.next/server/app`

Not ideal but looks like the easiest path for now.

---------

Co-authored-by: Burak Yigit Kaya <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Jul 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants